package com.example.cxf.controller;

import com.example.cxf.model.Result;
import com.example.cxf.model.entity.VehicleInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@Slf4j
@RestController
@RequestMapping("/vehicle")
@Api(tags = "车辆信息")
public class VehicleInfoController {

    @GetMapping("/getVehicleInfo")
    @ApiOperation(value = "查询车辆详情", notes = "根据id查询某辆车的详情")
    Result<VehicleInfo> getVehicleInfo(@RequestParam String id) {
        VehicleInfo vehicleInfo = new VehicleInfo();
        vehicleInfo.setId(id);
        vehicleInfo.setPlatesNumber("湘A88888");
        vehicleInfo.setRegisterDate(new Date());
        vehicleInfo.setCreateTime(new Date());
        return Result.ok(vehicleInfo);
    }

    @PostMapping("/saveVehicleInfo")
    @ApiOperation(value = "保存车辆数据")
    Result<?> saveVehicleInfo(@RequestBody VehicleInfo vehicleInfo) {
        log.info("saveVehicleInfo: {}", vehicleInfo.getPlatesNumber());
        return Result.ok("保存成功");
    }
}
